package models

import (
	"gameserver/gcommon"

	"gitee.com/night-tc/gobige/logger"
	"gitee.com/night-tc/gobige/msgdef"
	"gitee.com/night-tc/gobige/msgdef/protomsg"
)

type BaseMsgProc struct {
	User *RobotUser // 玩家对象
}

func (this *BaseMsgProc) MsgProc_DefaultMsgHandler(content msgdef.IMsg) {
	logger.Debugf(gcommon.LogKey_Robot, "%s GatewayMsg.MsgProc_DefaultMsgHandler: %s; msg:%s", this.User, content.Name(), content)
}

func (this *BaseMsgProc) MsgProc_MsgRet(msg *protomsg.MsgRet) {
	if msg.RetCode == 0 {
		return
	}
	switch msg.RetMsgID {
	default:
		logger.Warnf("%s GatewayMsg.MsgProc_MsgRet: %d; msg:%d", this.User, msg.RetMsgID, msg.RetCode)
	}
}

func (this *BaseMsgProc) MsgProc_SessClosed(msg *protomsg.SessClosed) {
	logger.Warnf("%s GatewayMsg.MsgProc_SessClosed", this.User)
	if this.User != nil {
		this.User.Stop()
	}
}
